#ifndef APP_RENDERER_HPP
#define APP_RENDERER_HPP

#include <device/aerTexture.hpp>
#include <device/aerProgram.hpp>
#include <device/aerFrameBuffer.hpp>

#include <postprocess/aerPostProcess.hpp>
#include <postprocess/aerBloomEffect.hpp>
#include <postprocess/aerDoFEffect.hpp>
#include <postprocess/aerPassthrough.hpp>

//#include <postprocess/aerDoFEffectKusma.hpp>//

#include "Data.hpp"
#include "Lighting.hpp"


///
/// Handles the rendering process
///
class Renderer
{
  private:
    struct GBuffer 
    {
      aer::Texture diffuse;
      aer::Texture normal;
      aer::Texture motionDoF;
      aer::Texture depthStencil;
      
      aer::FrameBuffer framebuffer;
    };
    
    struct CompositionPass
    {
      aer::Program program;
      aer::Texture color;
      aer::FrameBuffer framebuffer;
    };
    
    struct Effects
    {
      aer::BloomEffect bloom;
      aer::DoFEffect dof;
      aer::Passthrough passthrough;//
    };
  
  
  private:
    int m_width;
    int m_height;
    
    GBuffer m_gbuffer;    
    CompositionPass m_compositionPass;
    Lighting m_lighting;
        
    aer::PostProcess m_postProcess;
    Effects m_effects;
    
    
  public:
    Renderer();
    ~Renderer();
    
    void init(Data &data);
    void resize( const int width, const int height);
    
    void update(Data &data);    
    void run(Data &data);
    
  
  private:
    void compositionPass();
    void postProcess();// tmp
};

#endif // APP_RENDERER_HPP
